package action;

import java.util.Hashtable;
import java.util.Locale;
import java.util.Map;
import java.util.ResourceBundle;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

/**
 * @author dingyuanwei
 * @version 建立時間：Dec 24, 20101:33:18 PM
 * 類別說明:
 */
public class ChooseLanguageAction extends ActionSupport{
	private Locale current;
	private String textStr;
	public Map getLocales(){
		Map locales = new Hashtable(2);
		ResourceBundle bundle =  ResourceBundle.getBundle("messages.globalMessage_en_US",current);
		locales.put(bundle.getString("en"), Locale.US);
		locales.put(bundle.getString("cn"), Locale.CHINA);
		return locales;
	}
	
	@Override
	public String execute() throws Exception {
		String  ac = ServletActionContext.getRequest().getParameter("request_locale");
		System.out.println(ac);
		return SUCCESS;
	}
	public Locale getCurrent() {
		return current;
	}
	public void setCurrent(Locale current) {
		this.current = current;
	}

	public String getName() {
		return "aaaaa";
	}

	public String takeName(){
		return "aaaaa";
	}

	public String getTextStr() {
		return textStr;
	}

	public void setTextStr(String textStr) {
		this.textStr = textStr;
	}
	
	public String repeat(int count,String s){
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < count; i++) {
			sb.append(s);
		}
		return sb.toString();
	}
	
	
}
